package B_DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import B_DB.B_ProjectDB;


public class ZipcodeDAO {
	
	private static final String zipcodeSQL="select * from ZIPCODE where dong  like ?";

	public static ArrayList<String> findzip(String dong) {
		ArrayList<String> result =new ArrayList<String>();
		Connection conn=null;
		PreparedStatement ps = null;
		ResultSet rs=null;
		
		
		
			try{
			conn=B_ProjectDB.openzipcode();
			ps=conn.prepareStatement(zipcodeSQL);
			ps.setString(1, "%"+dong+"%");
			rs=ps.executeQuery();
			
			while(rs.next()){
				StringBuilder sb = new StringBuilder();
				sb.append(rs.getString(1)).append(" ");
				sb.append(rs.getString(3)).append(" ");
				sb.append(rs.getString(4)).append(" ");
				sb.append(rs.getString(5)).append(" ");
				sb.append(rs.getString(6)).append(" ");
				sb.append(rs.getString(8)).append(" ");
				sb.append(rs.getString(9)).append(" ");
				result.add(sb.toString());
			
			}
			}		catch (Exception ex){
			ex.printStackTrace();
		}finally{
			B_ProjectDB.closeConn(conn, ps, rs);
		}
		
		return result;
	}

}
